#pragma once

#include "Model.hpp"

class ModelLayer {

	friend class Scene;
	
private:

	GLboolean enableFlag = true;
	
public:

	void enbale();

	void disable();
	
	const GLboolean isEnable() const;

private:

	std::set <Model*> modelSet;
	
public:

	void attachModel(Model* model);
	
	void detachModel(Model* model);
	
	void detachAllModels();
	
private:
	
	void draw();

};

void ModelLayer::enbale(){
	enableFlag = true;
}

void ModelLayer::disable(){
	enableFlag = false;
}

const GLboolean ModelLayer::isEnable() const{
	return enableFlag;
}

void ModelLayer::attachModel(Model* model){
	if (model)
		modelSet.insert(model);
}

void ModelLayer::detachModel(Model* model){
	modelSet.erase(model);
}

void ModelLayer::detachAllModels(){
	modelSet.clear();
}

void ModelLayer::draw(){
	if (enableFlag)
		for (auto it = modelSet.begin(); it != modelSet.end(); ++it)
			(*it)->draw();
}
